package com.corona.game;

import com.badlogic.gdx.math.GridPoint2;
import com.badlogic.gdx.math.Vector3;
import com.corona.Game;
import com.corona.game.action.DrawAction;
import com.corona.game.util.GameProfiler;
import java.util.Iterator;

/* compiled from: PkmnMap.java */
/* loaded from: pokewilds.jar:com/pkmngen/game/DrawMapTrees.class */
public class DrawMapTrees extends DrawAction {
    Vector3 startPos;
    Vector3 endPos;
    Tile tile;
    public Action.Layer layer = Action.Layer.map_115;
    GridPoint2 topLeft = new GridPoint2();

    public DrawMapTrees(GameProfiler profiler) {
        super(profiler);
    }

    @Override // com.corona.game.Action
    public Action.Layer getLayer() {
        return this.layer;
    }

    @Override // com.corona.game.action.DrawAction
    protected void draw(Game game) {
        if (!game.player.dontDrawMapDuringBattle) {
            int i = 0;
            while (i < game.map.onscreenYsort1.size()) {
                PkmnMap.YSort ySort = game.map.onscreenYsort1.get(i);
                if (((float) ySort.yPos) <= game.player.position.y) {
                    break;
                }
                for (int j = 0; j < ySort.ySortPokemon.size(); j++) {
                    Pokemon pokemon = ySort.ySortPokemon.get(j);
                    if (pokemon.drawUpper != null) {
                        pokemon.drawUpper.draw(game);
                    }
                }
                for (int j2 = 0; j2 < ySort.ySortSavannaTrees.size(); j2++) {
                    Tile tile = ySort.ySortSavannaTrees.get(j2);
                    game.mapBatch.draw(tile.overSprite.getTexture(), tile.overSprite.getX(), tile.overSprite.getY() + 16.0f, tile.overSprite.getRegionX(), tile.overSprite.getRegionY(), tile.overSprite.getRegionWidth(), tile.overSprite.getRegionHeight() - 16);
                }
                for (int j3 = 0; j3 < ySort.ySortTrees.size(); j3++) {
                    Tile tile2 = ySort.ySortTrees.get(j3);
                    game.mapBatch.draw(tile2.overSprite.getTexture(), tile2.overSprite.getX(), tile2.overSprite.getY() + 8.0f, tile2.overSprite.getRegionX(), tile2.overSprite.getRegionY(), tile2.overSprite.getRegionWidth(), tile2.overSprite.getRegionHeight() - 8);
                }
                i++;
            }
            if (!(game.player.hmPokemon == null || game.player.hmPokemon.drawUpper == null)) {
                game.player.hmPokemon.drawUpper.draw(game);
            }
            game.player.drawPlayerUpper.step(game);
            while (i < game.map.onscreenYsort1.size()) {
                PkmnMap.YSort ySort2 = game.map.onscreenYsort1.get(i);
                Iterator<Pokemon> it = ySort2.ySortPokemon.iterator();
                while (it.hasNext()) {
                    Pokemon pokemon2 = it.next();
                    if (pokemon2.drawUpper != null) {
                        pokemon2.drawUpper.draw(game);
                    }
                }
                Iterator<Tile> it2 = ySort2.ySortSavannaTrees.iterator();
                while (it2.hasNext()) {
                    Tile tile3 = it2.next();
                    game.mapBatch.draw(tile3.overSprite.getTexture(), tile3.overSprite.getX(), tile3.overSprite.getY() + 16.0f, tile3.overSprite.getRegionX(), tile3.overSprite.getRegionY(), tile3.overSprite.getRegionWidth(), tile3.overSprite.getRegionHeight() - 16);
                }
                Iterator<Tile> it3 = ySort2.ySortTrees.iterator();
                while (it3.hasNext()) {
                    Tile tile4 = it3.next();
                    game.mapBatch.draw(tile4.overSprite.getTexture(), tile4.overSprite.getX(), tile4.overSprite.getY() + 8.0f, tile4.overSprite.getRegionX(), tile4.overSprite.getRegionY(), tile4.overSprite.getRegionWidth(), tile4.overSprite.getRegionHeight() - 8);
                }
                i++;
            }
        }
    }
}
